/*****************************************************************************
*
*  PROJECT:		
*               
*  LICENSE:		
*
*  DEVELOPER:	
*
*****************************************************************************/

#include "EonEffectsMgr.h"

int Eon::EffectsMgr::init( void )
{
	cgContext = cgCreateContext();

	if ( cgContext == NULL )
	{
		MessageBox(NULL, "Failed to create Cg context", "Error", MB_OK);
		return FALSE;
	}

	cgVertexProfile = cgGLGetLatestProfile( CG_GL_VERTEX );

	if ( cgVertexProfile == CG_PROFILE_UNKNOWN )
	{
		MessageBox(NULL, "Invalid Vertex Profile type", "Error", MB_OK);
		return FALSE;
	}

	cgFragmentProfile = cgGLGetLatestProfile( CG_GL_FRAGMENT );

	if ( cgFragmentProfile == CG_PROFILE_UNKNOWN )
	{
		MessageBox(NULL, "Invalid Fragment Profile type", "Error", MB_OK);
		return FALSE;
	}

	cgGLSetOptimalOptions( cgVertexProfile );
	cgGLSetOptimalOptions( cgFragmentProfile );

	// Load all shader programs here into their own CGprogram variables.
	// Refractive Environment Mapping Programs.
	cgVertexProgramRefractiveEnvironmentMapping		= cgCreateProgramFromFile( cgContext, CG_SOURCE, "vsRefractiveEnvironmentMapping.cg", cgVertexProfile, "main", 0 );
	cgFragmentProgramRefractiveEnvironmentMapping	= cgCreateProgramFromFile( cgContext, CG_SOURCE, "fsRefractiveEnvironmentMapping.cg", cgFragmentProfile, "main", 0 );
	// Chromatic Dispersion Programs.
	cgVertexProgramChromaticDispersion				= cgCreateProgramFromFile( cgContext, CG_SOURCE, "vsChromaticDispersion.cg", cgVertexProfile, "main", 0 );
	cgFragmentProgramChromaticDispersion			= cgCreateProgramFromFile( cgContext, CG_SOURCE, "fsChromaticDispersion.cg", cgFragmentProfile, "main", 0 );
	// Reflective Environment Mapping Programs.
	cgVertexProgramReflectiveEnvironmentMapping		= cgCreateProgramFromFile( cgContext, CG_SOURCE, "vsReflectiveEnvironmentMapping.cg", cgVertexProfile, "main", 0 );
	cgFragmentProgramReflectiveEnvironmentMapping	= cgCreateProgramFromFile( cgContext, CG_SOURCE, "fsReflectiveEnvironmentMapping.cg", cgFragmentProfile, "main", 0 );
	// Per Vertex Lighting Programs.
	cgVertexProgramPerVertexLighting				= cgCreateProgramFromFile( cgContext, CG_SOURCE, "vsPerVertexLighting.cg", cgVertexProfile, "main", 0 );
	cgFragmentProgramPerVertexLighting				= cgCreateProgramFromFile( cgContext, CG_SOURCE, "fsPerVertexLighting.cg", cgFragmentProfile, "main", 0 );
	// Per Fragment Lighting Programs.
	cgVertexProgramPerFragmentLighting				= cgCreateProgramFromFile( cgContext, CG_SOURCE, "vsPerFragmentLighting.cg", cgVertexProfile, "main", 0 );
	cgFragmentProgramPerFragmentLighting			= cgCreateProgramFromFile( cgContext, CG_SOURCE, "fsPerFragmentLighting.cg", cgFragmentProfile, "main", 0 );

	if ( cgVertexProgramRefractiveEnvironmentMapping == NULL || cgFragmentProgramRefractiveEnvironmentMapping == NULL ||
		 cgVertexProgramChromaticDispersion			 == NULL || cgVertexProgramChromaticDispersion			  == NULL ||
		 cgVertexProgramReflectiveEnvironmentMapping == NULL || cgFragmentProgramReflectiveEnvironmentMapping == NULL ||
		 cgVertexProgramPerVertexLighting			 == NULL || cgFragmentProgramPerVertexLighting			  == NULL ||
		 cgVertexProgramPerFragmentLighting			 == NULL || cgFragmentProgramPerFragmentLighting		  == NULL )
	{
		CGerror Error = cgGetError();

		MessageBox(NULL, cgGetErrorString(Error), "Error", MB_OK);
		return FALSE;
	}

	return TRUE;
}

void Eon::EffectsMgr::enableRefractiveEnvironmentMapping( Eon::Skybox skybox, Eon::Camera camera, Eon::Model::modelMD5 model, GLfloat modelTransmittance, GLfloat modelEtaRatio, GLuint decalMapTexture )
{
	cgGLLoadProgram( cgVertexProgramRefractiveEnvironmentMapping );
	cgGLLoadProgram( cgFragmentProgramRefractiveEnvironmentMapping );

	// Vertex program parameters
	CGparameter cgModelViewProj			= cgGetNamedParameter( cgVertexProgramRefractiveEnvironmentMapping, "modelViewProj" );
	CGparameter cgModelToWorld			= cgGetNamedParameter( cgVertexProgramRefractiveEnvironmentMapping, "modelToWorld" );
	CGparameter cgEyePos				= cgGetNamedParameter( cgVertexProgramRefractiveEnvironmentMapping, "eyePos" );
	CGparameter cgEtaRatio				= cgGetNamedParameter( cgVertexProgramRefractiveEnvironmentMapping, "etaRatio" );
	// Fragment program parameters
	CGparameter cgEnvironmentMap		= cgGetNamedParameter( cgFragmentProgramRefractiveEnvironmentMapping, "environmentMap" );
	CGparameter cgDecalMap				= cgGetNamedParameter( cgFragmentProgramRefractiveEnvironmentMapping, "decalMap" );
	CGparameter cgTransmittance			= cgGetNamedParameter( cgFragmentProgramRefractiveEnvironmentMapping, "transmittance" );

	GLfloat eyePos[]		= { camera.getPosition().getX(), camera.getPosition().getY(), camera.getPosition().getZ() };
	GLfloat etaRatio[]		= { modelEtaRatio };
	GLfloat transmittance[] = { modelTransmittance };
	GLuint cubeMapTexture	= skybox.getCubeMapTexture();

	// Get fragment shader parameters
	cgGLSetTextureParameter							( cgEnvironmentMap, cubeMapTexture );
	cgGLEnableTextureParameter						( cgEnvironmentMap );

	cgGLSetTextureParameter							( cgDecalMap, decalMapTexture );
	cgGLEnableTextureParameter						( cgDecalMap );

	cgGLSetParameter1f								( cgTransmittance, transmittance[0] );
	cgGLSetParameter1f								( cgEtaRatio, etaRatio[0] );
	cgGLSetParameter3fv								( cgEyePos, eyePos );							// Pass the position of the camera as an array [ x, y, z ]

	glPushMatrix();
		glLoadIdentity();			// Load the identity matrix before setting the world view matrix in Cg

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelToWorld, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	glPushMatrix();
		// CRITICAL!
		// Do NOT load the identity matrix when setting the model view projection matrix

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	// Bind the programs and enable the profiles
	cgGLBindProgram( cgVertexProgramRefractiveEnvironmentMapping );
	cgGLEnableProfile( cgVertexProfile );
	cgGLBindProgram( cgFragmentProgramRefractiveEnvironmentMapping );
	cgGLEnableProfile( cgFragmentProfile );
}

void Eon::EffectsMgr::enableRefractiveEnvironmentMapping( Eon::Skybox skybox, Eon::Camera camera, Eon::Model::model3DS model, GLfloat modelTransmittance, GLfloat modelEtaRatio, GLuint decalMapTexture )
{
	cgGLLoadProgram( cgVertexProgramRefractiveEnvironmentMapping );
	cgGLLoadProgram( cgFragmentProgramRefractiveEnvironmentMapping );

	// Vertex program parameters
	CGparameter cgModelViewProj			= cgGetNamedParameter( cgVertexProgramRefractiveEnvironmentMapping, "modelViewProj" );
	CGparameter cgModelToWorld			= cgGetNamedParameter( cgVertexProgramRefractiveEnvironmentMapping, "modelToWorld" );
	CGparameter cgEyePos				= cgGetNamedParameter( cgVertexProgramRefractiveEnvironmentMapping, "eyePos" );
	CGparameter cgEtaRatio				= cgGetNamedParameter( cgVertexProgramRefractiveEnvironmentMapping, "etaRatio" );
	// Fragment program parameters
	CGparameter cgEnvironmentMap		= cgGetNamedParameter( cgFragmentProgramRefractiveEnvironmentMapping, "environmentMap" );
	CGparameter cgDecalMap				= cgGetNamedParameter( cgFragmentProgramRefractiveEnvironmentMapping, "decalMap" );
	CGparameter cgTransmittance			= cgGetNamedParameter( cgFragmentProgramRefractiveEnvironmentMapping, "transmittance" );

	GLfloat eyePos[]		= { camera.getPosition().getX(), camera.getPosition().getY(), camera.getPosition().getZ() };
	GLfloat etaRatio[]		= { modelEtaRatio };
	GLfloat transmittance[] = { modelTransmittance };
	GLuint cubeMapTexture	= skybox.getCubeMapTexture();

	// Get fragment shader parameters
	cgGLSetTextureParameter							( cgEnvironmentMap, cubeMapTexture );
	cgGLEnableTextureParameter						( cgEnvironmentMap );

	cgGLSetTextureParameter							( cgDecalMap, decalMapTexture );
	cgGLEnableTextureParameter						( cgDecalMap );

	cgGLSetParameter1f								( cgTransmittance, transmittance[0] );
	cgGLSetParameter1f								( cgEtaRatio, etaRatio[0] );
	cgGLSetParameter3fv								( cgEyePos, eyePos );							// Pass the position of the camera as an array [ x, y, z ]

	glPushMatrix();
		glLoadIdentity();			// Load the identity matrix before setting the world view matrix in Cg

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelToWorld, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	glPushMatrix();
		// CRITICAL!
		// Do NOT load the identity matrix when setting the model view projection matrix

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	// Bind the programs and enable the profiles
	cgGLBindProgram( cgVertexProgramRefractiveEnvironmentMapping );
	cgGLEnableProfile( cgVertexProfile );
	cgGLBindProgram( cgFragmentProgramRefractiveEnvironmentMapping );
	cgGLEnableProfile( cgFragmentProfile );
}

void Eon::EffectsMgr::enableChromaticDispersion( Eon::Skybox skybox, Eon::Camera camera, Eon::Model::modelMD5 model, GLfloat modelEtaRatio, GLfloat modelFresnelBias, GLfloat modelFresnelScale, GLfloat modelFresnelPower )
{
	cgGLLoadProgram( cgVertexProgramChromaticDispersion );
	cgGLLoadProgram( cgFragmentProgramChromaticDispersion );

	// Vertex program parameters
	CGparameter cgModelViewProj			= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "modelViewProj" );
	CGparameter cgModelToWorld			= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "modelToWorld" );
	CGparameter cgEyePos				= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "eyePos" );
	CGparameter cgEtaRatio				= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "etaRatio" );
	CGparameter cgFresnelBias			= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "fresnelBias" );
	CGparameter cgFresnelScale			= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "fresnelScale" );
	CGparameter cgFresnelPower			= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "fresnelPower" );
	// Fragment program parameters
	CGparameter cgEnvironmentMap0		= cgGetNamedParameter( cgFragmentProgramChromaticDispersion, "environmentMap0" );
	CGparameter cgEnvironmentMap1		= cgGetNamedParameter( cgFragmentProgramChromaticDispersion, "environmentMap1" );
	CGparameter cgEnvironmentMap2		= cgGetNamedParameter( cgFragmentProgramChromaticDispersion, "environmentMap2" );
	CGparameter cgEnvironmentMap3		= cgGetNamedParameter( cgFragmentProgramChromaticDispersion, "environmentMap3" );

	GLfloat eyePos[]		= { camera.getPosition().getX(), camera.getPosition().getY(), camera.getPosition().getZ() };
	GLfloat etaRatio[]		= { modelEtaRatio, modelEtaRatio - 0.05f, modelEtaRatio - 0.05f };
	GLfloat fresnelBias[]	= { modelFresnelBias };
	GLfloat fresnelScale[]	= { modelFresnelScale };
	GLfloat fresnelPower[]	= { modelFresnelPower };
	GLuint cubeMapTexture	= skybox.getCubeMapTexture();

	cgGLSetTextureParameter( cgEnvironmentMap0, cubeMapTexture );
	cgGLEnableTextureParameter( cgEnvironmentMap0 );

	cgGLSetTextureParameter( cgEnvironmentMap1, cubeMapTexture );
	cgGLEnableTextureParameter( cgEnvironmentMap1 );

	cgGLSetTextureParameter( cgEnvironmentMap2, cubeMapTexture );
	cgGLEnableTextureParameter( cgEnvironmentMap2 );

	cgGLSetTextureParameter( cgEnvironmentMap3, cubeMapTexture );
	cgGLEnableTextureParameter( cgEnvironmentMap3 );

	cgGLSetParameter3fv	( cgEtaRatio, etaRatio );
	cgGLSetParameter1f	( cgFresnelBias, fresnelBias[0] );
	cgGLSetParameter1f	( cgFresnelScale, fresnelScale[0] );
	cgGLSetParameter1f	( cgFresnelPower, fresnelPower[0] );
	cgGLSetParameter3fv	( cgEyePos, eyePos );

	glPushMatrix();
	glLoadIdentity();			// Load the identity matrix before setting the world view matrix in Cg

	// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
	glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
	glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
	glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
	glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
	glScalef( model.getScale(), model.getScale(), model.getScale() );

	cgGLSetStateMatrixParameter( cgModelToWorld, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	glPushMatrix();
	// CRITICAL!
	// Do NOT load the identity matrix when setting the model view projection matrix

	// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
	glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
	glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
	glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
	glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
	glScalef( model.getScale(), model.getScale(), model.getScale() );

	cgGLSetStateMatrixParameter( cgModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	cgGLBindProgram( cgVertexProgramChromaticDispersion );
	cgGLEnableProfile( cgVertexProfile );
	cgGLBindProgram( cgFragmentProgramChromaticDispersion);
	cgGLEnableProfile( cgFragmentProfile);
}

void Eon::EffectsMgr::enableChromaticDispersion( Eon::Skybox skybox, Eon::Camera camera, Eon::Model::model3DS model, GLfloat modelEtaRatio, GLfloat modelFresnelBias, GLfloat modelFresnelScale, GLfloat modelFresnelPower )
{
	cgGLLoadProgram( cgVertexProgramChromaticDispersion );
	cgGLLoadProgram( cgFragmentProgramChromaticDispersion );

	// Vertex program parameters
	CGparameter cgModelViewProj			= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "modelViewProj" );
	CGparameter cgModelToWorld			= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "modelToWorld" );
	CGparameter cgEyePos				= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "eyePos" );
	CGparameter cgEtaRatio				= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "etaRatio" );
	CGparameter cgFresnelBias			= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "fresnelBias" );
	CGparameter cgFresnelScale			= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "fresnelScale" );
	CGparameter cgFresnelPower			= cgGetNamedParameter( cgVertexProgramChromaticDispersion, "fresnelPower" );
	// Fragment program parameters
	CGparameter cgEnvironmentMap0		= cgGetNamedParameter( cgFragmentProgramChromaticDispersion, "environmentMap0" );
	CGparameter cgEnvironmentMap1		= cgGetNamedParameter( cgFragmentProgramChromaticDispersion, "environmentMap1" );
	CGparameter cgEnvironmentMap2		= cgGetNamedParameter( cgFragmentProgramChromaticDispersion, "environmentMap2" );
	CGparameter cgEnvironmentMap3		= cgGetNamedParameter( cgFragmentProgramChromaticDispersion, "environmentMap3" );

	GLfloat eyePos[]		= { camera.getPosition().getX(), camera.getPosition().getY(), camera.getPosition().getZ() };
	GLfloat etaRatio[]		= { modelEtaRatio, modelEtaRatio - 0.05f, modelEtaRatio - 0.05f };
	GLfloat fresnelBias[]	= { modelFresnelBias };
	GLfloat fresnelScale[]	= { modelFresnelScale };
	GLfloat fresnelPower[]	= { modelFresnelPower };
	GLuint cubeMapTexture	= skybox.getCubeMapTexture();

	cgGLSetTextureParameter( cgEnvironmentMap0, cubeMapTexture );
	cgGLEnableTextureParameter( cgEnvironmentMap0 );

	cgGLSetTextureParameter( cgEnvironmentMap1, cubeMapTexture );
	cgGLEnableTextureParameter( cgEnvironmentMap1 );

	cgGLSetTextureParameter( cgEnvironmentMap2, cubeMapTexture );
	cgGLEnableTextureParameter( cgEnvironmentMap2 );

	cgGLSetTextureParameter( cgEnvironmentMap3, cubeMapTexture );
	cgGLEnableTextureParameter( cgEnvironmentMap3 );

	cgGLSetParameter3fv	( cgEtaRatio, etaRatio );
	cgGLSetParameter1f	( cgFresnelBias, fresnelBias[0] );
	cgGLSetParameter1f	( cgFresnelScale, fresnelScale[0] );
	cgGLSetParameter1f	( cgFresnelPower, fresnelPower[0] );
	cgGLSetParameter3fv	( cgEyePos, eyePos );

	glPushMatrix();
		glLoadIdentity();			// Load the identity matrix before setting the world view matrix in Cg

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelToWorld, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	glPushMatrix();
		// CRITICAL!
		// Do NOT load the identity matrix when setting the model view projection matrix

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	cgGLBindProgram( cgVertexProgramChromaticDispersion );
	cgGLEnableProfile( cgVertexProfile );
	cgGLBindProgram( cgFragmentProgramChromaticDispersion);
	cgGLEnableProfile( cgFragmentProfile);
}

void Eon::EffectsMgr::enableReflectiveEnvironmentMapping( Eon::Skybox skybox, Eon::Camera camera, Eon::Model::modelMD5 model, GLfloat modelReflectivity, GLuint decalMapTexture )
{
	cgGLLoadProgram( cgVertexProgramReflectiveEnvironmentMapping );
	cgGLLoadProgram( cgFragmentProgramReflectiveEnvironmentMapping );

	// Vertex program parameters
	CGparameter cgModelViewProj		= cgGetNamedParameter( cgVertexProgramReflectiveEnvironmentMapping, "modelViewProj" );
	CGparameter cgModelToWorld		= cgGetNamedParameter( cgVertexProgramReflectiveEnvironmentMapping, "modelToWorld" );
	CGparameter cgEyePos			= cgGetNamedParameter( cgVertexProgramReflectiveEnvironmentMapping, "eyePos" );
	// Fragment program parameters
	CGparameter cgReflectivity		= cgGetNamedParameter( cgFragmentProgramReflectiveEnvironmentMapping, "reflectivity" );
	CGparameter cgDecalMap			= cgGetNamedParameter( cgFragmentProgramReflectiveEnvironmentMapping, "decalMap" );
	CGparameter cgEnvironmentMap	= cgGetNamedParameter( cgFragmentProgramReflectiveEnvironmentMapping, "environmentMap" );

	GLfloat eyePos[]		= { camera.getPosition().getX(), camera.getPosition().getY(), camera.getPosition().getZ() };
	GLfloat reflectivity[]	= { modelReflectivity };
	GLuint cubeMapTexture	= skybox.getCubeMapTexture();

	cgGLSetTextureParameter( cgEnvironmentMap, cubeMapTexture );
	cgGLEnableTextureParameter( cgEnvironmentMap );

	cgGLSetTextureParameter( cgDecalMap, decalMapTexture );
	cgGLEnableTextureParameter( cgDecalMap );

	cgGLSetParameter1f( cgReflectivity, reflectivity[0] );
	cgGLSetParameter3fv( cgEyePos, eyePos );
	
	glPushMatrix();
		glLoadIdentity();			// Load the identity matrix before setting the world view matrix in Cg

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelToWorld, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	glPushMatrix();
		// CRITICAL!
		// Do NOT load the identity matrix when setting the model view projection matrix

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	cgGLBindProgram( cgVertexProgramReflectiveEnvironmentMapping );
	cgGLEnableProfile( cgVertexProfile );
	cgGLBindProgram( cgFragmentProgramReflectiveEnvironmentMapping );
	cgGLEnableProfile( cgFragmentProfile );
}

void Eon::EffectsMgr::enableReflectiveEnvironmentMapping( Eon::Skybox skybox, Eon::Camera camera, Eon::Model::model3DS model, GLfloat modelReflectivity, GLuint decalMapTexture )
{
	cgGLLoadProgram( cgVertexProgramReflectiveEnvironmentMapping );
	cgGLLoadProgram( cgFragmentProgramReflectiveEnvironmentMapping );

	// Vertex program parameters
	CGparameter cgModelViewProj		= cgGetNamedParameter( cgVertexProgramReflectiveEnvironmentMapping, "modelViewProj" );
	CGparameter cgModelToWorld		= cgGetNamedParameter( cgVertexProgramReflectiveEnvironmentMapping, "modelToWorld" );
	CGparameter cgEyePos			= cgGetNamedParameter( cgVertexProgramReflectiveEnvironmentMapping, "eyePos" );
	// Fragment program parameters
	CGparameter cgReflectivity		= cgGetNamedParameter( cgFragmentProgramReflectiveEnvironmentMapping, "reflectivity" );
	CGparameter cgDecalMap			= cgGetNamedParameter( cgFragmentProgramReflectiveEnvironmentMapping, "decalMap" );
	CGparameter cgEnvironmentMap	= cgGetNamedParameter( cgFragmentProgramReflectiveEnvironmentMapping, "environmentMap" );

	GLfloat eyePos[] = { camera.getPosition().getX(), camera.getPosition().getY(), camera.getPosition().getZ() };
	GLfloat reflectivity[] = { modelReflectivity };
	GLuint cubeMapTexture = skybox.getCubeMapTexture();

	cgGLSetTextureParameter( cgEnvironmentMap, cubeMapTexture );
	cgGLEnableTextureParameter( cgEnvironmentMap );

	cgGLSetTextureParameter( cgDecalMap, decalMapTexture );
	cgGLEnableTextureParameter( cgDecalMap );

	cgGLSetParameter1f( cgReflectivity, reflectivity[0] );
	cgGLSetParameter3fv( cgEyePos, eyePos );

	glPushMatrix();
		glLoadIdentity();			// Load the identity matrix before setting the world view matrix in Cg

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelToWorld, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	glPushMatrix();
		// CRITICAL!
		// Do NOT load the identity matrix when setting the model view projection matrix

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	cgGLBindProgram( cgVertexProgramReflectiveEnvironmentMapping );
	cgGLEnableProfile( cgVertexProfile );
	cgGLBindProgram( cgFragmentProgramReflectiveEnvironmentMapping );
	cgGLEnableProfile( cgFragmentProfile );
}

void Eon::EffectsMgr::enablePerVertexLighting(	Eon::Camera camera, Eon::Model::modelMD5 model, Eon::Vector3 lightPosition, Eon::Vector3 lightColor, Eon::Vector3 globalAmbient, 
												Eon::Vector3 emissiveLight, Eon::Vector3 ambientLight, Eon::Vector3 diffuseLight, Eon::Vector3 specularLight, 
												GLfloat shininess )
{
	cgGLLoadProgram( cgVertexProgramPerVertexLighting );
	cgGLLoadProgram( cgFragmentProgramPerVertexLighting );

	// Vertex program parameters
	CGparameter cgModelViewProj = cgGetNamedParameter( cgVertexProgramPerVertexLighting, "modelViewProj" );
	CGparameter cgLightPos		= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "lightPos" );
	CGparameter cgLightColor	= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "lightColor" );
	CGparameter cgGlobalAmbient = cgGetNamedParameter( cgVertexProgramPerVertexLighting, "globalAmbient" );
	CGparameter cgEyePos		= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "eyePos" );
	CGparameter cgKe			= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "Ke" );
	CGparameter cgKa			= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "Ka" );
	CGparameter cgKd			= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "Kd" );
	CGparameter cgKs			= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "Ks" );
	CGparameter cgShininess		= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "shininess" );

	GLfloat eyePos[]		= { camera.getPosition().getX(), camera.getPosition().getY(), camera.getPosition().getZ() };
	GLfloat lightPos[]		= { lightPosition.getX(), lightPosition.getY(), lightPosition.getZ() };
	GLfloat lightCol[]		= { lightColor.getX(), lightColor.getY(), lightColor.getZ() };
	GLfloat globalAmb[]		= { globalAmbient.getX(), globalAmbient.getY(), globalAmbient.getZ() };
	GLfloat emissive[]		= { emissiveLight.getX(), emissiveLight.getY(), emissiveLight.getZ() };
	GLfloat ambient[]		= { ambientLight.getX(), ambientLight.getY(), ambientLight.getZ() };
	GLfloat diffuse[]		= { diffuseLight.getX(), diffuseLight.getY(), diffuseLight.getZ() };
	GLfloat specular[]		= { specularLight.getX(), specularLight.getY(), specularLight.getZ() };
	GLfloat shine[]			= { shininess };

	cgGLSetParameter3fv( cgLightColor, lightCol );
	cgGLSetParameter3fv( cgLightPos, lightPos );
	cgGLSetParameter3fv( cgGlobalAmbient, globalAmb );
	cgGLSetParameter3fv( cgEyePos, eyePos );
	cgGLSetParameter3fv( cgKe, emissive );
	cgGLSetParameter3fv( cgKa, ambient );
	cgGLSetParameter3fv( cgKd, diffuse );
	cgGLSetParameter3fv( cgKs, specular );
	cgGLSetParameter1f( cgShininess, shine[0] );

	glPushMatrix();
	// CRITICAL!
	// Do NOT load the identity matrix when setting the model view projection matrix

	// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
	glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
	glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
	glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
	glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
	glScalef( model.getScale(), model.getScale(), model.getScale() );

	cgGLSetStateMatrixParameter( cgModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	cgGLBindProgram( cgVertexProgramPerVertexLighting );
	cgGLEnableProfile( cgVertexProfile );
	cgGLBindProgram( cgFragmentProgramPerVertexLighting );
	cgGLEnableProfile( cgFragmentProfile );
}

void Eon::EffectsMgr::enablePerVertexLighting(	Eon::Camera camera, Eon::Model::model3DS model, Eon::Vector3 lightPosition, Eon::Vector3 lightColor, Eon::Vector3 globalAmbient, 
												Eon::Vector3 emissiveLight, Eon::Vector3 ambientLight, Eon::Vector3 diffuseLight, Eon::Vector3 specularLight, 
												GLfloat shininess )
{
	cgGLLoadProgram( cgVertexProgramPerVertexLighting );
	cgGLLoadProgram( cgFragmentProgramPerVertexLighting );

	// Vertex program parameters
	CGparameter cgModelViewProj = cgGetNamedParameter( cgVertexProgramPerVertexLighting, "modelViewProj" );
	CGparameter cgLightPos		= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "lightPos" );
	CGparameter cgLightColor	= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "lightColor" );
	CGparameter cgGlobalAmbient = cgGetNamedParameter( cgVertexProgramPerVertexLighting, "globalAmbient" );
	CGparameter cgEyePos		= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "eyePos" );
	CGparameter cgKe			= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "Ke" );
	CGparameter cgKa			= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "Ka" );
	CGparameter cgKd			= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "Kd" );
	CGparameter cgKs			= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "Ks" );
	CGparameter cgShininess		= cgGetNamedParameter( cgVertexProgramPerVertexLighting, "shininess" );

	GLfloat eyePos[]		= { camera.getPosition().getX(), camera.getPosition().getY(), camera.getPosition().getZ() };
	GLfloat lightPos[]		= { lightPosition.getX(), lightPosition.getY(), lightPosition.getZ() };
	GLfloat lightCol[]		= { lightColor.getX(), lightColor.getY(), lightColor.getZ() };
	GLfloat globalAmb[]		= { globalAmbient.getX(), globalAmbient.getY(), globalAmbient.getZ() };
	GLfloat emissive[]		= { emissiveLight.getX(), emissiveLight.getY(), emissiveLight.getZ() };
	GLfloat ambient[]		= { ambientLight.getX(), ambientLight.getY(), ambientLight.getZ() };
	GLfloat diffuse[]		= { diffuseLight.getX(), diffuseLight.getY(), diffuseLight.getZ() };
	GLfloat specular[]		= { specularLight.getX(), specularLight.getY(), specularLight.getZ() };
	GLfloat shine[]			= { shininess };

	cgGLSetParameter3fv( cgLightColor, lightCol );
	cgGLSetParameter3fv( cgLightPos, lightPos );
	cgGLSetParameter3fv( cgGlobalAmbient, globalAmb );
	cgGLSetParameter3fv( cgEyePos, eyePos );
	cgGLSetParameter3fv( cgKe, emissive );
	cgGLSetParameter3fv( cgKa, ambient );
	cgGLSetParameter3fv( cgKd, diffuse );
	cgGLSetParameter3fv( cgKs, specular );
	cgGLSetParameter1f( cgShininess, shine[0] );

	glPushMatrix();
		// CRITICAL!
		// Do NOT load the identity matrix when setting the model view projection matrix

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	cgGLBindProgram( cgVertexProgramPerVertexLighting );
	cgGLEnableProfile( cgVertexProfile );
	cgGLBindProgram( cgFragmentProgramPerVertexLighting );
	cgGLEnableProfile( cgFragmentProfile );
}

void Eon::EffectsMgr::enablePerFragmentLighting(	Eon::Camera camera, Eon::Model::modelMD5 model, Eon::Vector3 lightPosition, Eon::Vector3 lightColor, Eon::Vector3 globalAmbient, 
													Eon::Vector3 emissiveLight, Eon::Vector3 ambientLight, Eon::Vector3 diffuseLight, Eon::Vector3 specularLight, 
													GLfloat shininess )
{
	cgGLLoadProgram( cgVertexProgramPerFragmentLighting );
	cgGLLoadProgram( cgFragmentProgramPerFragmentLighting );

	// Vertex program parameters
	CGparameter cgModelViewProj = cgGetNamedParameter( cgVertexProgramPerFragmentLighting, "modelViewProj" );
	// Fragment program parameters
	CGparameter cgLightPos		= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "lightPos" );
	CGparameter cgLightColor	= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "lightColor" );
	CGparameter cgGlobalAmbient = cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "globalAmbient" );
	CGparameter cgEyePos		= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "eyePos" );
	CGparameter cgKe			= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "Ke" );
	CGparameter cgKa			= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "Ka" );
	CGparameter cgKd			= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "Kd" );
	CGparameter cgKs			= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "Ks" );
	CGparameter cgShininess		= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "shininess" );

	GLfloat eyePos[]		= { camera.getPosition().getX(), camera.getPosition().getY(), camera.getPosition().getZ() };
	GLfloat lightPos[]		= { lightPosition.getX(), lightPosition.getY(), lightPosition.getZ() };
	GLfloat lightCol[]		= { lightColor.getX(), lightColor.getY(), lightColor.getZ() };
	GLfloat globalAmb[]		= { globalAmbient.getX(), globalAmbient.getY(), globalAmbient.getZ() };
	GLfloat emissive[]		= { emissiveLight.getX(), emissiveLight.getY(), emissiveLight.getZ() };
	GLfloat ambient[]		= { ambientLight.getX(), ambientLight.getY(), ambientLight.getZ() };
	GLfloat diffuse[]		= { diffuseLight.getX(), diffuseLight.getY(), diffuseLight.getZ() };
	GLfloat specular[]		= { specularLight.getX(), specularLight.getY(), specularLight.getZ() };
	GLfloat shine[]			= { shininess };

	cgGLSetParameter3fv( cgLightColor, lightCol );
	cgGLSetParameter3fv( cgLightPos, lightPos );
	cgGLSetParameter3fv( cgGlobalAmbient, globalAmb );
	cgGLSetParameter3fv( cgEyePos, eyePos );
	cgGLSetParameter3fv( cgKe, emissive );
	cgGLSetParameter3fv( cgKa, ambient );
	cgGLSetParameter3fv( cgKd, diffuse );
	cgGLSetParameter3fv( cgKs, specular );
	cgGLSetParameter1f( cgShininess, shine[0] );

	glPushMatrix();
		// CRITICAL!
		// Do NOT load the identity matrix when setting the model view projection matrix

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	cgGLBindProgram( cgVertexProgramPerFragmentLighting );
	cgGLEnableProfile( cgVertexProfile );
	cgGLBindProgram( cgFragmentProgramPerFragmentLighting );
	cgGLEnableProfile( cgFragmentProfile );
}

void Eon::EffectsMgr::enablePerFragmentLighting(	Eon::Camera camera, Eon::Model::model3DS model, Eon::Vector3 lightPosition, Eon::Vector3 lightColor, Eon::Vector3 globalAmbient, 
													Eon::Vector3 emissiveLight, Eon::Vector3 ambientLight, Eon::Vector3 diffuseLight, Eon::Vector3 specularLight, 
													GLfloat shininess )
{
	cgGLLoadProgram( cgVertexProgramPerFragmentLighting );
	cgGLLoadProgram( cgFragmentProgramPerFragmentLighting );

	// Vertex program parameters
	CGparameter cgModelViewProj = cgGetNamedParameter( cgVertexProgramPerFragmentLighting, "modelViewProj" );
	// Fragment program parameters
	CGparameter cgLightPos		= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "lightPos" );
	CGparameter cgLightColor	= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "lightColor" );
	CGparameter cgGlobalAmbient = cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "globalAmbient" );
	CGparameter cgEyePos		= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "eyePos" );
	CGparameter cgKe			= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "Ke" );
	CGparameter cgKa			= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "Ka" );
	CGparameter cgKd			= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "Kd" );
	CGparameter cgKs			= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "Ks" );
	CGparameter cgShininess		= cgGetNamedParameter( cgFragmentProgramPerFragmentLighting, "shininess" );

	GLfloat eyePos[]		= { camera.getPosition().getX(), camera.getPosition().getY(), camera.getPosition().getZ() };
	GLfloat lightPos[]		= { lightPosition.getX(), lightPosition.getY(), lightPosition.getZ() };
	GLfloat lightCol[]		= { lightColor.getX(), lightColor.getY(), lightColor.getZ() };
	GLfloat globalAmb[]		= { globalAmbient.getX(), globalAmbient.getY(), globalAmbient.getZ() };
	GLfloat emissive[]		= { emissiveLight.getX(), emissiveLight.getY(), emissiveLight.getZ() };
	GLfloat ambient[]		= { ambientLight.getX(), ambientLight.getY(), ambientLight.getZ() };
	GLfloat diffuse[]		= { diffuseLight.getX(), diffuseLight.getY(), diffuseLight.getZ() };
	GLfloat specular[]		= { specularLight.getX(), specularLight.getY(), specularLight.getZ() };
	GLfloat shine[]			= { shininess };

	cgGLSetParameter3fv( cgLightColor, lightCol );
	cgGLSetParameter3fv( cgLightPos, lightPos );
	cgGLSetParameter3fv( cgGlobalAmbient, globalAmb );
	cgGLSetParameter3fv( cgEyePos, eyePos );
	cgGLSetParameter3fv( cgKe, emissive );
	cgGLSetParameter3fv( cgKa, ambient );
	cgGLSetParameter3fv( cgKd, diffuse );
	cgGLSetParameter3fv( cgKs, specular );
	cgGLSetParameter1f( cgShininess, shine[0] );

	glPushMatrix();
		// CRITICAL!
		// Do NOT load the identity matrix when setting the model view projection matrix

		// Remember to perform these translations in the same order as when rendering the model otherwise you may get unexpected results (model will appear in the wrong location)
		glTranslatef( model.getPosition().getX(), model.getPosition().getY(), model.getPosition().getZ() );
		glRotatef( model.getRotation().getX(), 1.0f, 0.0f, 0.0f );
		glRotatef( model.getRotation().getY(), 0.0f, 1.0f, 0.0f );
		glRotatef( model.getRotation().getZ(), 0.0f, 0.0f, 1.0f );
		glScalef( model.getScale(), model.getScale(), model.getScale() );

		cgGLSetStateMatrixParameter( cgModelViewProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
	glPopMatrix();

	cgGLBindProgram( cgVertexProgramPerFragmentLighting );
	cgGLEnableProfile( cgVertexProfile );
	cgGLBindProgram( cgFragmentProgramPerFragmentLighting );
	cgGLEnableProfile( cgFragmentProfile );
}

void Eon::EffectsMgr::disableShader( void )
{
	cgGLDisableProfile( cgVertexProfile );
	cgGLDisableProfile( cgFragmentProfile );
}

void Eon::EffectsMgr::destroy( void )
{
	cgDestroyContext( cgContext );
}